package hotLeetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class H73Leetcode {
    public void setZeroes(int[][] matrix) {
         //先找出为零的位置
        List<int[]> list = new ArrayList<>();
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[i].length; j++) {
                if (matrix[i][j] == 0) list.add(new int[]{i, j});
            }
        }


        for (int[] arr : list) {
            int i = arr[0];
            int j = arr[1];
            System.out.println("("+ i+","+ j+")");
            //行
            for (int y = 0; y < matrix[i].length; y++) {
                matrix[i][y] = 0;
            }
            //列
            for (int x = 0; x < matrix.length; x++) {
                matrix[x][j] = 0;
            }

        }


        show(matrix);

    }

    public static void main(String[] args) {
        int[][] matrix = {{0, 1, 2, 0}, {3, 4, 5, 2}, {1, 3, 1, 5}};
        H73Leetcode h73Leetcode = new H73Leetcode();
        h73Leetcode.setZeroes(matrix);


    }

    private void show(int[][] arr) {

        for (int[] nums : arr) {
            System.out.println(Arrays.toString(nums));

        }
    }
}
